package com.jason.learn.springcloud.orderservice.maper;


import com.jason.learn.springcloud.orderservice.enty.BuyOrder;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Mapper
@Repository
public interface OrderMapper {
    @Select("SELECT order_id,create_time,mer_no,amount,status FROM t_order")
    List<BuyOrder> findAll();

    @Select("SELECT order_id,create_time,mer_no,amount,status,buyer_card FROM t_order WHERE create_time > #{startTime} and create_time < #{endTime}")
    List<BuyOrder> findAllByTime(Long startTime, Long endTime);

    @Select("SELECT order_id,create_time,mer_no,amount,status,buyer_card FROM t_order WHERE order_id=#{orderId} and create_time > #{beginTime} and create_time < #{endTime}")
    BuyOrder findOne(Map param);

    @Select("SELECT order_id,create_time,mer_no,amount,status,buyer_card FROM t_order WHERE order_id=#{orderId}")
    BuyOrder findById(Long orderId);

    @Insert("INSERT INTO t_order(create_time,mer_no,amount,status,buyer_card) values(#{createTime},#{merNo},#{amount},#{status},#{buyerCard})")
    Long insert(BuyOrder order);

    @Update("UPDATE t_order SET STATUS = #{update_status} WHERE order_id = #{orderId} and STATUS = #{status}")
    void updateOrder(Long orderId,int status,int update_status);
}
